#include"processtar.h"
#include<string.h>
#define NUM 100

void  FlushProcess(double total,double current){
    char buffer[NUM];
    const char* a="|/-\\";
    memset(buffer,0,sizeof(buffer));
    int len=strlen(a);
    //填充#号
    //需要计算填充几个
    int num=(int)(current*100/total);//保留整数个
    int i=0;
    for(i=0;i<num;i++){
        buffer[i]='#';
    }
    double n=current/total;
    static int con=0; 
    printf("[%-100s][%.f%%][%c]\r",buffer,n*100,a[con%len]);
    fflush(stdout);
    con++;
}

void process_test(){
    char buffer[NUM];
   const char* a="|/-\\";
    memset(buffer,0,sizeof(buffer));
    int i=0;
    while(i<=100){
        printf("[%-100s][%d%%][%c]\r",buffer,i,a[i%strlen(a)]);
        fflush(stdout);
        buffer[i]='#';
        i++;
        usleep(100000);
    }
    printf("\n");
}
